package net.mlike.openssp.server.controller;

import net.mlike.openssp.server.dto.Message;
import net.mlike.openssp.server.entity.system.User;
import net.mlike.openssp.server.search.system.UserSearch;
import net.mlike.openssp.server.service.system.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * Created by wallellen@hotmail.com on 5/24/18.
 */
@Controller
@RequestMapping(name = "/api/users")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public String index() {
        return "system/user/index";
    }

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Message list(UserSearch search) {
        Page<User> users = userService.findBySearch(search);
        return Message.success(users);
    }
}
